Vietnamese ID Card Recognition
Requirements
- The input image must have 4 clear angles or all main components of a Vietnamese ID card such as document title, contents, etc.
- All information fields must be visible, readable, unmodified, not blurred.
- The input image must contains only one document, as well as none of other objects with text on them.
- The input image size does not exceed 5 MB and the minimum resolution is approximately 1280x720 to ensure the confident rate.
- The ratio of Vietnamese ID card area must be at least 2/3 of the total image area.
Request
Request Url
POST https://api.fpt.ai/vision/vnm/id-fraudcheck
Request Headers
| Parameter | Required | Default | Description |
|---|---|---|---|
| api_key | Yes | Your api key ( get from console.fpt.ai ) |
Request Body
In order to recognize an Vietnamese ID Card on the photo, a single image or image URL must be sent with the request by using one in 5 keys below:
| Parameter | Required | Type | Description |
|---|---|---|---|
| image | No. Set either this parameter or image_url or image_base64. | File | Image file |
| image_url | No. Set either this parameter or image or image_base64. | String | Image URL. Currently, HTTP/HTTPS URLs are supported |
| image_base64 | No. Set either this parameter or image or image_url. | String | Image in the form of base64 string |
| image_list[] | No. Set either this parameter or image or image_url or image_base64. | String | List of image files |
| url_list[] | No. Set either this parameter or image or image_url or image_base64. | String | List of image URLs |
Sample Request
Using image
curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image=@/path/to/image' \
--form 'face=1'
Using URL
curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_url=link/to/image' \
--form 'face=1'
Using base64-string image
curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_base64=image/in/form/of/base64-string' \
--form 'face=1'
Using list of images
curl --location --request POST 'https://api.fpt.ai/vision/vnm/id-fraudcheck' \
--header 'api_key: xxxxxxx' \
--form 'image_list[]=@/path/to/image/of/front/side' \
--form 'image_list[]=@/path/to/image/of/back/side' \
--form 'face=1'
Response
JSON
{
"errorCode" : x,
"errorMessage" : "xxxx",
"data" : [xxxx]
}
The system is able to extract the information of Vietnamese ID card plus several checking results to make sure the integrity of the ID card image. The checking result includes fraud check before the OCR process has finished and post check after the OCR process has finished. Currently, all types of Vietnamese ID card are supported, including the old type, the new type, and the has-chip ID card:
- old Vietnamese ID card front side
- old Vietnamese ID card back side
- new Vietnamese ID card front side.
- new Vietnamese ID card back side.
- has-chip Vietnamese ID card front side.
- has-chip Vietnamese ID card back side.
- new has-chip Vietnamese ID card front side.
- new has-chip Vietnamese ID card back side.
Note:
- old Vietnamese ID card: applies to the 9-digit ID card
- new Vietnamese ID card: applies to the 12-digit ID card, no chip
- has-chip Vietnamese ID card: applies to the 12-digit ID card, has chip, issued from Jan 23, 2021 to Jun 30, 2024.
- new has-chip Vietnamese ID card: applies to the 12-digit ID card, has chip, issued from July 1, 2024.
After successfully sending the request, the system will return a json file that includes text information about the image quality using the format below:
- errorCode: value is 0 if the request was successful with no error occurred
- errorMessage: value is equal to empty string if the request was successful with no error occurred
- data: includes all information about the content in the ID card and the checking results if the request succeeds without errors or return empty list [] if an error occurs. Also included with the information returned is the probability that indicates the reliability of the returned results. Besides, the data field also includes fraud-check results and post-check results (check the details below).
(The detail of the errors that might occure include both errorCode and errorMessage is described on Errors)
Data
{
"errorCode": 0,
"errorMessage": "",
"data": [
{
"id": "xxxxx",
"id_prob": "84.91",
"name": "xxxxx",
"name_prob": "91.73",
"dob": "xxxxx",
"dob_prob": "96.58",
"sex": "xxxxx",
"sex_prob": "99.78",
"nationality": "xxxxx",
"nationality_prob": "99.11",
"type_new": "xxxxx",
"doe": "xxxxx",
"doe_prob": "97.79",
"home": "xxxxx",
"home_prob": "92.71",
"address": "xxxxx",
"address_prob": "99.07",
"address_entities": {
"province": "xxxxx",
"district": "xxxxx",
"ward": "xxxxx",
"street": "xxxxx"
},
"QRcode": "ID number|Old ID number|Name|Date of birth|Gender|Address|Issue date",
"comparing_qrcode_result": {
"result": "Failed",
"code": "E01",
"message": "At least a field is not correct",
"different_fields": [
"id",
"name",
"dob",
"address"
]
},
"overall_score": "87.61",
"type": "new",
"checking_result": {
"recaptured_result": "0",
"recaptured_prob": "0.02",
"edited_result": "1",
"edited_prob": "0.97",
"corner_cut_result": "0",
"corner_cut_prob": [
"0.00",
"0.00",
"0.00",
"0.00"
],
"check_photocopied_result": "0",
"check_photocopied_prob": "0.27",
"check_title_result": "passed",
"check_title_prob": [
"0.67",
"0.49"
],
"check_emblem_result": "passed",
"check_emblem_prob": "0.76",
"check_fingerprint_result": "N/A",
"check_fingerprint_prob": [],
"check_stamp_result": "N/A",
"check_stamp_prob": [],
"check_embossed_stamp_result": "failed",
"check_embossed_stamp_prob": "0.00",
"check_border_result": "failed",
"check_border_prob": "0.71",
"low_score_result": [
"id",
]
},
"face": "/direct/link/to/face/image",
"face_base64": "/face/image/in/base64"
"cropped_idcard": "/direct/link/to/cropped/ID/card/image",
"cropped_idcard_base64": "/cropped/image/in/base64"
},
{
"post_check_result": {
"result": "Passed",
"code": "E00",
"message": ""
}
}
]
}
Information Extraction results
The old type Vietnamese ID card front side composes of 5 data fields:
| Field | Description |
|---|---|
| id | ID number |
| name | Name |
| dob | Date of birth |
| home | Original place |
| address | Address |
The old type Vietnamese ID card back side composes of 5 data fields:
| Field | Description |
|---|---|
| ethnicity | Ethnicity |
| religion | Religion |
| features | Personal mark and disfigurement |
| issue_date | Issue date |
| issue_loc | Issue location |
The new (no-chip)/has-chip type Vietnamese ID card (Căn cước công dân loại cũ và Căn cước công dân có chip) front side composes of 8 data fields:
| Field | Description |
|---|---|
| id | ID number |
| name | Name |
| dob | Date of birth |
| home | Original place |
| address | Address |
| sex | Gender |
| nationality/ethnicity | Nationality/ Ethnicity |
| doe | Expiry date |
The new (no-chip)/has-chip type Vietnamese ID card back side composes of 2 or 3 data fields:
| Field | Description |
|---|---|
| features | Personal mark and disfigurement |
| issue_date | Issue date |
| mrz | MRZ code (only in has-chip type) |
The new has-chip type Vietnamese ID card front side composes of 5 data fields:
| Field | Description |
|---|---|
| id | ID number |
| name | Name |
| dob | Date of birth |
| sex | Gender |
| nationality | Nationality |
The new has-chip type Vietnamese ID card back side composes of 5 data fields:
| Field | Description |
|---|---|
| address | Address |
| pob | Place of birth |
| issue_date | Issue date |
| doe | Expiry date |
| mrz | MRZ code (only in has-chip type) |
Besides, there are 3 additional data fields, including:
| Field | Description |
|---|---|
| type | includes 8 types:
|
| type_new | ID cards are separated into smaller classes which differentiate 2 types of new ID card; including 9 types:
|
| address_entities | the raw address will be standardized and separated into 4 parts:
|
| address_entity_with_code | the raw address will be standardized, separated into 4 parts and mapped with location codes as in this link location codes:
|
Fraud-check results
The fraud-check results includes 16 fields of information:
| Field | Description |
|---|---|
| recaptured_result | Checking result of recapturing document from a LCD screen |
| edited_result | Checking result of the document that has been edited |
| corner_cut_result | Checking result of the document that has a cutting corner |
| check_photocopied_result | Checking result of the document that has been BW photocopied |
| check_emblem_result | Checking result of the front side of document that if its national emblem is covered/missing |
| check_headline_result | Checking result of the front side of document that if its headline is covered/missing |
| check_title_result | Checking result of the front side of document that if its title is covered/missing |
| check_fingerprint_result | Checking result of the document that if its fingerprints on the back side are covered/missing |
| check_stamp_result | Checking result of the document that if its stamp on the back side is covered/missing |
| check_QRcode_result | Checking result of the document that if it is has-chip ID card and its QRcode is covered/missing |
| check_chip_result | Checking result of the back side of document that if its chip is covered/missing |
| check_mrz_result | Checking result of the document that if it is has-chip ID card and its MRZ on the back side is covered/missing |
| check_covering_result | Checking result of that if there is any objects cover on the document |
| check_embossed_stamp_result | Checking result of the document that if its embossed stamp on the frontside is covered/missing |
| check_border_result | Checking result of the document that if its border is covered |
| low_score_result | List of fields contain low-score characters |
| check_watermark_result | Checking result of the image of document that if it has watermark or not |
| check_anti_counterfeiting_stamps_result | Checking result of the image of back side of document that if it has anti-counterfeiting stamps or not |
| check_face_result | Checking result of the image of front side of document that if it has a human portrait or not |
The results of following criteria are in 1/0, in which 1 means yes and 0 means no (so good image should has all-0s results):
- recaptured_result (applied for both sides): is "1" if "recaptured_prob" > 0.5, otherwise "0"
- edited_result (applied for front side, back side "N/A"): is "1" if "edited_prob" > 0.6, otherwise "0"
- corner_cut_result (applied for both sides): is "1" if one of "corner_cut_prob" > 0.5, otherwise "0"
- check_photocopied_result (applied for both sides): is "1" if "check_photocopied_prob" >= 0.5, otherwise "0"
The results of following criteria are in passed/failed, so good image should has all-passed results:
- check_emblem_result (applied for front side, back side "N/A"): is "passed" if "check_emblem_prob" >= 0.7, otherwise "failed"
- check_headline_result (applied for front side, back side "N/A"): is "passed" if "check_headline_prob" >= 0.7, otherwise "failed"
- check_title_result (applied for front side, back side "N/A"): is "passed" if "check_title_prob" >= 0.7, otherwise "failed"
- check_fingerprint_result (applied for back side, front side "N/A"): is "passed" if both scores in "check_fingerprint_prob" >= 0.7, otherwise "failed"
- check_stamp_result (applied for back side, front side "N/A"): is "passed" if "check_stamp_prob" >= 0.7, otherwise "failed"
- check_QRcode_result (applied for front side of has-chip ID card, back side "N/A"): is "passed" if "check_QRcode_prob" >= 0.9, otherwise "failed"
- check_chip_result (applied for back side of has-chip ID card, front side "N/A"): is "passed" if "check_chip_result" >= 0.7, otherwise "failed"
- check_mrz_result (applied for back side of has-chip ID card, front side "N/A"): is "passed" if "check_mrz_prob" >= 0.75, otherwise "failed"
- check_covering_result (experimental - applied for both sides): is "passed" if "check_covering_prob" < 0.5, otherwise "failed"
- check_embossed_stamp_result (experimental - applied for front side of old ID card, back side "N/A"): is "passed" if "check_fingerprint_prob" >= 0.7, otherwise "failed"
- check_border_result (experimental - applied for both sides of old type ID card): is "failed" if "check_border_result" >= 0.5, otherwise "passed"
The result of criterion low_score_result is the list of fields that contain low-score characters.
Comparing_qrcode_result
The "comparing_qrcode_result" to show the comparing result between QR code result and OCR result with several information (comparing result, error code, message, list of different fields):
"comparing_qrcode_result": {
"result": "Failed",
"code": "E01",
"message": "At least a field is not correct",
"different_fields": [
"name",
"address"
]
}
List of comparing_qrcode error messages:
| Code | Mesage | Description (Vietnamese) |
|---|---|---|
| E00 | Passed | Kiểm tra thành công |
| E01 | At least a field is not correct | Có ít nhất một trường thông tin nào đó không chính xác |
| E02 | Undefined error | Có lỗi bất thường xảy ra |
| E03 | Cannot read QR Code | Không đọc thành công QR Code |
Post-check results
The post-check process will check the integrity in the information extracted from the document (1 side or 2 sides). For example: date of birth format, date of issuing format, ID number should match date of birth and address, etc. (check below for the details). If all the post-check tests are passed, the result will be:
{
"post_check_result": {
"result": "Passed",
"code": "E00",
"message": ""
}
}
In the case of not passing any tests, the result will be "Failed" and include the failing message. For example:
{
"post_check_result": {
"result": "Failed",
"code": "E08",
"message": "Gender code is not match"
}
}
Post-check process

List of post-check error messages:
| Code | Mesage | Description (Vietnamese) | Description (English) |
|---|---|---|---|
| E00 | Passed | Kiểm tra thành công | The OCR result is successfully passed the check |
| E01 | There is a NULL field | Có một trường thông tin nào đó bị trống | There is atleast a field of information is blank. Consider do the OCR again |
| E02 | ID format is not correct | Cấu trúc số ID không đúng | The structure of ID number is not correct. It is maybe the signal of bad OCR result or fraud |
| E03 | DoB format is not correct | Cấu trúc của ngày sinh không đúng | The structure of date of birth is not correct |
| E04 | DoB is later than today | Ngày sinh không thể sau ngày hôm nay | Date of birth is later than today. It is maybe the signal of bad OCR result or fraud |
| E05 | Current age cannot smaller than 14 | Tuổi hiện tại không thể dưới 14 | The old type of ID card cannot be issued to under-14 children. This is maybe the signal of bad OCR result or fraud |
| E07 | Year in DoB is not match with ID number | Năm sinh không khớp với số ID | Year of birth should be match with ID number |
| E08 | Gender code is not match | Mã giới tính không khớp với số ID | Gender code should be match with ID number |
| E09 | DoE format is not correct | Cấu trúc ngày hết hạn không đúng | The structure of date of expiration is not correct |
| E10 | ID card has been expired | Giấy tờ hết hạn | The document is expired |
| E11 | DoE cannot be "KHÔNG THỜI HẠN" | Trường hợp chỉ gửi mặt trước và người mang giấy tờ dưới 58 tuổi vào thời điểm hiện tại thì ngày hết hạn không thể là "KHÔNG THỜI HẠN" | If the document in submitted image is front side of ID card with chip and the document holder is currently under 58, then the expiration date cannot be "KHÔNG THỜI HẠN" |
| E12 | DoI format is not correct | Cấu trúc ngày cấp không đúng | The structure of date of issue is not correct |
| E13 | DoI is later than today | Ngày cấp sau ngày hôm nay | Date of issue is later than today. It is maybe the signal of bad OCR result or fraud |
| E14 | Reserved for later use | ||
| E15 | Please send images of front and back side of same type ID (old or new ID) | Trường hợp gửi cả 2 mặt trong 1 request và đang gửi mặt trước + mặt sau của 2 loại giấy tờ khác nhau | The case that two images of two sides are submitted in the same request and they are not from the same type of document (old / new / chip) |
| E17 | Age at issue date cannot smaller than 14 | Trường hợp gửi cả 2 mặt trong 1 request và tuổi trên giấy tờ dưới 14 ở thời điểm cấp | The old type of ID card cannot be issued to under-14 children. This is maybe the signal of bad OCR result or fraud |
| E18 | DoE should be DoI + 15 years | Trường hợp gửi cả 2 mặt trong 1 request và giấy tờ là Chứng minh nhân dân 12 số, ngày hết hạn là ngày cấp cộng thêm 15 năm | The case that two images of two sides are submitted in the same request and the document is 12-digit ID card, then the expiration date should be equal to the issue date plus 15 years |
| E19 | DoE should be birthday at 25 years old | Trường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 23 và trên 14 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 25 tuổi | The case that two images of two sides are submitted in the same request and the document holder is under 23 and over 14 at the issue date, then the expiration date should be 25th birthday |
| E20 | DoE should be birthday at 40 years old | Trường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 38 và trên 23 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 40 tuổi | The case that two images of two sides are submitted in the same request and the document holder is under 38 and over 23 at the issue date, then the expiration date should be 40th birthday |
| E21 | DoE should be birthday at 60 years old | Trường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ dưới 58 và trên 38 vào ngày cấp, thì ngày hết hạn phải là sinh nhật 60 tuổi | The case that two images of two sides are submitted in the same request and the document holder is under 58 and over 38 at the issue date, then the expiration date should be 60th birthday |
| E22 | DoE should be "KHÔNG THỜI HẠN" | Trường hợp gửi cả 2 mặt trong 1 request và nếu tuổi trên giấy tờ trên 58 vào ngày cấp, thì ngày hết hạn phải là "KHÔNG THỜI HẠN" | The case that two images of two sides are submitted in the same request and the document holder is over 58 at the issue date, then the expiration date should be "KHÔNG THỜI HẠN" |
| E30 | Front and back side are not from the same ID card | Trường hợp gửi cả 2 mặt trong 1 request và loại giấy tờ là Căn cước công dân gắn chip. Thông tin mặt sau không khớp với thông tin của mặt trước | The case that two images of two sides are submitted in the same request and they are not from the same document |
| E31 | Issue location does not match issue date | Áp dụng cho trường hợp Căn cước công dân không chip: nơi cấp thay đổi theo từng thời kỳ phát hành. | Applying for the case of no-chip ID, the IDs that were issued in different periods have different issue locations |
| E32 | Type of document does not match issue date | Áp dụng cho trường hợp Căn cước công dân có chip: CCCD có chip bắt đầu được phát hành từ ngày 23/01/2021. Với trường hợp Căn cước 2024: CC bắt đầu được phát hành từ ngày 01/07/2024. | Applying for the case of has-chip ID, the date of issue on has-chip ID should be from 23/01/2021. Applying for the case of new has-chip ID (ID card 2024), the date of issue on new has-chip ID should be from 01/07/2024 |
| E33 | DoE should be birthday at 14 years old | Áp dụng cho trường hợp Căn cước mới 2024 có chip: Ngày hết hạn phải là ngày sinh nhật 14 tuổi. | Applying for the case of has-chip ID New 2024, Expiration date must be 14th birthday |
| E36 | Current age cannot smaller than 6 | Tuổi hiện tại không thể dưới 6 | The ID card 2024 type not for children cannot be issued to under-6 children. This is maybe the signal of bad OCR result or fraud |
| E37 | Age at issue date cannot smaller than 6 | Tuổi trên giấy tờ dưới 6 ở thời điểm cấp đối với Căn cước 2024 | The ID card 2024 type not for children cannot be issued to under-6 children. This is maybe the signal of bad OCR result or fraud |
| QR01 | QR code does not match OCR result | Trường hợp trong các giấy tờ gửi lên có bao gồm mặt trước của Căn cước công dân gắn chip hoặc mặt sau của Căn cước mới và cờ verify_qrcode=1. Kết quả QRcode đọc được không khớp với kết quả OCR | The case that documents in the submitted images includes front side of ID card with chip or back side of new has-chip ID card and the flag verify_qrcode=1, then the QRcode result should be match with OCR result |
| QR02 | QR code format is not correct | Trường hợp có cờ verify_qrcode=1. Kết quả QRcode đọc được không khớp với format QRcode nên có của loại giấy tờ | The case that flag verify_qrcode=1, the QR code result does not match the expected format of the document’s QR code |
Errors
The system uses the error codes as follows:
| Error Code | Meaning |
|---|---|
| -1 | Undefined error -- Undefined error from system (this error should not happened in normal case) |
| 0 | No error -- This is a successful call, no error |
| 1 | Invalid Parameters or Values! -- Wrong parameter in the request (e.g. no key or image in the request body). |
| 3 | Unable to find ID card in the image -- The system cannot find the Vietnamese ID card in the image or the image is of poor quality (too blur, too dark/bright). |
| 5 | No URL in the request -- The request uses the image_url key but the value is left blank. |
| 6 | Failed to open the URL! -- The request uses the image_url key but the system cannot open this URL. |
| 7 | Invalid image file -- The uploaded file is not an image file. |
| 8 | Bad data -- The uploaded image file is corrupted or the format is not supported. |
| 9 | No string base64 in the request -- The request uses image_base64 key but the value is left blank. |
| 10 | String base64 is not valid -- The request uses image_base64 key but the provided string is invalid. |
| 11 | Quality check failed -- For the case that using params quality_check=1 and quality check result is failed. |